package org.durandj.ystream.server.ui;

import java.util.Scanner;

import org.durandj.ystream.server.ClientManager;
import org.durandj.ystream.server.network.Client;

/**
 * A console that works off of the console. This is for the sticklers who hate GUI's. All
 * notifications and messages will go to the console. This UI is what restricts the loggers
 * to use a file stream rather than the console stream. Dang those hardcore 'Nixers!
 * 
 * @author durandj
 * @version 1.0
 *
 */
public class ConsoleUI implements ServerUI
{
	/**
	 * This is how the server gets input from the user with this UI.
	 */
	private Scanner consoleReader;
	
	/**
	 * This is the client manager reference that is used to listen
	 * for changes in the number of clients.
	 */
	private ClientManager clientManager;
	
	/**
	 * The thread of execution of the UI.
	 */
	private Thread thread;
	
	/**
	 * Creates a console UI.
	 */
	public ConsoleUI()
	{
		consoleReader = new Scanner(System.in);
		
		thread = new Thread(new Runnable() {
			@Override
			public void run()
			{
				// TODO Auto-generated method stub
				
			}
		});
		thread.start();
	}
	
	/* (non-Javadoc)
	 * @see org.durandj.ystream.server.ui.ServerUI#dispose()
	 */
	@Override
	public void destroy()
	{
		// TODO Auto-generated method stub
		
	}

	/* (non-Javadoc)
	 * @see org.durandj.ystream.server.ui.ServerUI#setClientManager(org.durandj.ystream.server.ClientManager)
	 */
	@Override
	public void setClientManager(ClientManager manager)
	{
		if(manager == null)
			throw new NullPointerException("Must give a valid client manager reference.");
		
		clientManager = manager;
	}
}
